//
// Created by liushuai on 2020/3/20.
//
#include "findCycle.h"
ListNode* findCycle(ListNode* head)
{
    ListNode* fast = head;
    ListNode* slow = head;
    while (slow && fast)
    {
        slow = slow->next;
        if (fast->next)
            fast = fast->next->next;
        else
            return nullptr;
        if (fast == slow)
            return slow;
    }
    return nullptr;
}
